(in-package :procemu)

(defclass memory-move (instruction)
  ;; Source and destination can be either memory addresses or registers
  ((source :initarg :source)
   (destination :initarg :destination))
  (:documentation "An instruction that moves something into or out of
memory"))

(defclass memory-load (memory-move) ())
(defclass memory-store (memory-move) ())

(defmethod perform ((instruction memory-load) (cpu cpu))
  (with-slots (source destination) instruction
    (setf (register cpu destination)
	  (memory cpu source))))

(defmethod perform ((instruction memory-store) (cpu cpu))
  (with-slots (source destination) instruction
    (setf (memory cpu destination)
	  (register cpu source))))